package com.skyworthclub.competition.controller;


import com.skyworthclub.competition.service.RoleService;
import com.skyworthclub.competition.utils.web.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author li
 * @since 2019-06-23
 */
@Controller
@RequestMapping("/api/admin/role")
public class RoleController {

    private final RoleService roleService;

    @Autowired
    public RoleController(RoleService roleService) {
        this.roleService = roleService;
    }


    @PostMapping("/grantAdmin/{userId}")
    public ResponseEntity<Map<String, Object>> grantAdmin(@PathVariable("userId") Integer userId) {
        roleService.grantAdminRole(userId);
        Map<String, Object> map = new HashMap<>(2);
        return ResponseUtil.putSuccessResponse(map);
    }
}

